Use Contents API instead of raw endpoint to fetch file content#1998
Merged
almaleksia merged 5 commits intomainfrom Feb 12, 2026
Merged
Use Contents API instead of raw endpoint to fetch file content#1998almaleksia merged 5 commits intomainfrom
almaleksia merged 5 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates get_file_contents to avoid the flaky raw content endpoint by relying on the GitHub Contents API for file retrieval, and returning an MCP ResourceLink for large files.
Changes:
- Switch
get_file_contentsto use Contents API content directly for files < 1MB, and return aResourceLink(plus download URL hint) for larger files. - Add a
NewToolResultResourceLinkhelper for returning tool results that include aResourceLink. - Add
expandRepoResourceURIto generate consistentrepo://...URIs across sha/ref cases, and update tests to cover the new behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/utils/result.go | Adds NewToolResultResourceLink helper to return a text message + ResourceLink in tool results. |
| pkg/github/repository_resource.go | Introduces expandRepoResourceURI helper for building repo:// URIs via templates for sha/ref/default. |
| pkg/github/repositories.go | Updates GetFileContents to stop using the raw endpoint, detect MIME from content, and return ResourceLink for large files. |
| pkg/github/repositories_test.go | Updates mocks/expectations for Contents API base64 content, MIME detection, and adds a large-file ResourceLink test. |
JoannaaKL
previously approved these changes
Feb 12, 2026
JoannaaKL
approved these changes
Feb 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moving
get_file_contentsto use Contents API for file content and removing usage of raw endpoint. The latter is flaky - it doesn't support all authentication form GitHub offers, which often result in failures.Previous logic:
New logic:
MIME type is derived from the content of a file.
Why
Fixes #
What changed
MCP impact
Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goNote: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.
Lint & tests
./script/lint./script/testDocs